<template>
  <BasicModal
    :open = "visable"
    :mask = false
    :draggable = false
    :closable = false
    :showCancelBtn = false
    @register="register"
    @ok = "login"
    title="登录框"
  >
    <el-form size="large" label-width="60px" :model="formInline" class="demo-form-inline">
      <el-form-item label="用户名">
        <el-input placeholder="请输入用户名" v-model="formInline.username" clearable style="width: 400px"/>
      </el-form-item>
      <el-form-item label="密码">
        <el-input  placeholder="请输入密码" v-model="formInline.password" clearable style="width: 400px"/>
      </el-form-item>
    </el-form>
<!--    <a-button type="primary" @click="closeModal" class="mr-2">从内部关闭弹窗</a-button>-->

<!--    <a-button type="primary" @click="setModalProps">从内部修改title</a-button>-->
  </BasicModal>
</template>
<script lang="ts">
import {defineComponent, ref} from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import {useRoute, useRouter} from "vue-router";
import * as API from '@/api/pbi/login';
import {
  APP_LOCAL_CACHE_KEY,
  APP_SESSION_CACHE_KEY,
  LOCK_INFO_KEY,
  TOKEN_KEY,
  USER_INFO_KEY
} from "@/enums/cacheEnum";
import {omit, pick} from "lodash-es";
export default defineComponent({
  components: { BasicModal},
  setup() {
    const formInline = ref({
      username: '',
      password: '',
    })
    const [register, { closeModal, setModalProps }] = useModalInner();
    const visable = ref(true);
    const route = useRoute();
    const router = useRouter();
    const menuFn = (menu, path,name) => {
      router.push({
        path,
      });
    };
    const login = async () => {
      const {query} = route
      let path = query.redirect
      debugger
      if (formInline.value.username != undefined && formInline.value.password != undefined && formInline.value.username != '' && formInline.value.password != '') {
        debugger
        let encodedStr = btoa(formInline.value.username + ':' + formInline.value.password);
        let Authorization = 'Basic ' + encodedStr;
        // let res = await API.loginCheck(Authorization,{})
        // console.log(res)
        localStorage.setItem("token", "test");
        router.push({path});
      }

      // console.log(query.redirect)

    }
    return {
      login,
      formInline,
      visable,
      register,
      closeModal,
      setModalProps: () => {
        setModalProps({ title: 'Modal New Title' });
      },
    };
  },
});
</script>
<style scoped>
</style>
